package com.lezhi.socialgram.util;

import com.lezhi.socialgram.exception.SocialGramException;
import org.slf4j.Logger;
import org.springframework.validation.BindingResult;

/**
 * Created by daizhen on 2017/3/26.
 */
public interface ValidUtils {

    static void valid(Logger logger, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            logger.error("valid error:{}", bindingResult.getAllErrors().get(0).getDefaultMessage());
            throw new SocialGramException(bindingResult.getAllErrors().get(0).getDefaultMessage());
        }
    }

}
